<?php

/*

Buy Penny Play Tickets (penny_play.pro.php)

*/
ob_start();
$rank_check = 1;
include "global.inc.php";

if ($buy_tickets > $points)
{
	die(header(error("penny_play.php?game=$game","You can't afford to buy $buy_tickets Penny Play tickets, sorry.")));
}

if ($buy_tickets <= 0)
{
	die(header(error("penny_play.php?game=$game","Please enter any number above 0.")));
}

$findRow = fetch("SELECT * FROM penny_play2 WHERE userid = '$userid' AND game = '$game'");
$buy_tickets2 = $buy_tickets;
if (($findRow[entries] + $buy_tickets2) > 30000)
{
	die(header(error("penny_play.php?game=$game","You can only buy 10,000 tickets a day!")));
}

if (!$findRow[id])
{
	mysql_query("INSERT INTO penny_play2 (userid,entries,game) VALUES ('$userid','$buy_tickets2','$game')");
	$take = "-$buy_tickets";
	points($game,$username,$take);
}
else
{
	mysql_query("UPDATE penny_play2 SET entries=$findRow[entries]+$buy_tickets2 WHERE userid = '$userid' AND game = '$game'");
	$take = "-$buy_tickets";
	points($game,$username,$take);
}

die(header(error("penny_play.php?game=$game","You have purchased $buy_tickets Penny Play tickets!!")));
?>